<template>
<view class="wel_box">
  <image class="back_img" mode="aspectFill" src="/static/pages/image/store_bg.png"></image>
  <button class="login_butt" open-type="getUserInfo" @getuserinfo="getUserInfo">登录</button>
</view>
</template>

<script>
var app = getApp();

export default {
  data() {
    return {
      parent_uid: 0,
      isShow: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (a) {
    var t = this;

    if (a && a.scene) {
      t.setData({
        parent_uid: a.scene
      });
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    getUserInfo: function (e) {
      var t = this;
      console.log('用户信息：', e);
      var id = e.detail.errMsg; // return;

      if (id == 'getUserInfo:ok') {
        app.globalData.util.getUserInfo(function (a) {
          console.log('getUserInfo:', a);
          a.memberInfo ? t.firstin(a.memberInfo) : t.setData({
            isShow: !0
          });
        }), wx.reLaunch({
          url: '../index/index'
        });
      }
    },
    firstin: function (a) {
      app.globalData.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "me.binding",
          uid: a.uid,
          head_image: a.avatar,
          nickname: a.nickname,
          parent_uid: this.parent_uid
        },
        success: function (a) {}
      });
    }
  }
};
</script>
<style>
@import "./welcome.css";
</style>